package com.objecteffects.template.tumblr.method;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import javax.validation.Valid;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

import com.objecteffects.template.tumblr.method.Likes.LikesResponse;

import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

/**
 * @author Rusty Wright
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
public class Likes extends BaseResponse<LikesResponse> {
    /**
     * @param meta
     * @param response
     */
    public Likes(@JsonProperty("meta")
    final Meta meta, @JsonProperty("response")
    final LikesResponse response) {
        super(meta, response);
    }

    // @JsonIgnore
    private final Map<String, Object> additionalProperties = new HashMap<>();

    @Override
    @JsonAnyGetter
    public Map<String, Object> getAdditionalProperties() {
        return this.additionalProperties;
    }

    @Override
    @JsonAnySetter
    public void setAdditionalProperty(final String name, final Object value) {
        this.additionalProperties.put(name, value);
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }

    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }

    @Override
    public boolean equals(final Object other) {
        return EqualsBuilder.reflectionEquals(this, other);
    }

    @JsonInclude(JsonInclude.Include.ALWAYS)
    public static class LikesResponse {
        private final List<LikedPost> likedPosts;
        private final Long likedCount;

        // @JsonIgnore
        private final Map<String, Object> additionalProperties =
            new HashMap<>();

        @JsonCreator
        public LikesResponse(@JsonProperty("liked_posts")
        final List<LikedPost> _likedPosts, @JsonProperty("liked_count")
        final Long _likedCount) {
            this.likedPosts = Objects.requireNonNull(_likedPosts);
            this.likedCount = _likedCount;
        }

        /**
         * @return the likedPosts
         */
        public List<LikedPost> getLikedPosts() {
            return this.likedPosts;
        }

        /**
         * @return the likedCount
         */
        public Long getLikedCount() {
            return this.likedCount;
        }

        @JsonAnyGetter
        public Map<String, Object> getAdditionalProperties() {
            return this.additionalProperties;
        }

        @JsonAnySetter
        public void
            setAdditionalProperty(final String name, final Object value) {
            this.additionalProperties.put(name, value);
        }

        @Override
        public String toString() {
            return ToStringBuilder.reflectionToString(this);
        }

        @Override
        public int hashCode() {
            return HashCodeBuilder.reflectionHashCode(this);
        }

        @Override
        public boolean equals(final Object other) {
            return EqualsBuilder.reflectionEquals(this, other);
        }

        @JsonInclude(JsonInclude.Include.NON_NULL)
        public static class LikedPost {
            private final String blogName;
            private final Long id;
            private final String postUrl;
            private final String slug;
            private final String type;
            private final String date;
            private final Long timestamp;
            private final String state;
            private final String format;
            private final String reblogKey;
            private final List<Object> tags;
            private final String shortUrl;
            private final Boolean followed;
            private final List<Object> highlighted;
            private final Boolean liked;
            private final Long noteCount;
            private final String sourceUrl;
            private final String sourceTitle;
            private final String caption;
            private final String linkUrl;
            private final String imagePermalink;
            private final List<Photo> photos;
            private final Boolean canReply;
            private final String postAuthor;
            private final Map<String, Object> additionalProperties =
                new HashMap<>();

            public LikedPost(@JsonProperty("blog_name")
            final String _blogName, @JsonProperty("id")
            final Long _id, @JsonProperty("post_url")
            final String _postUrl, @JsonProperty("slug")
            final String _slug, @JsonProperty("type")
            final String _type, @JsonProperty("date")
            final String _date, @JsonProperty("timestamp")
            final Long _timestamp, @JsonProperty("state")
            final String _state, @JsonProperty("format")
            final String _format, @JsonProperty("reblog_key")
            final String _reblogKey, @JsonProperty("tags")
            @Valid
            final List<Object> _tags, @JsonProperty("short_url")
            final String _shortUrl, @JsonProperty("followed")
            final Boolean _followed, @JsonProperty("highlighted")
            @Valid
            final List<Object> _highlighted, @JsonProperty("liked")
            final Boolean _liked, @JsonProperty("note_count")
            final Long _noteCount, @JsonProperty("source_url")
            final String _sourceUrl, @JsonProperty("source_title")
            final String _sourceTitle, @JsonProperty("caption")
            final String _caption, @JsonProperty("link_url")
            final String _linkUrl, @JsonProperty("image_permalink")
            final String _imagePermalink, @JsonProperty("photos")
            @Valid
            final List<Photo> _photos, @JsonProperty("can_reply")
            final Boolean _canReply, @JsonProperty("post_author")
            final String _postAuthor) {
                this.blogName = _blogName;
                this.id = _id;
                this.postUrl = _postUrl;
                this.slug = _slug;
                this.type = _type;
                this.date = _date;
                this.timestamp = _timestamp;
                this.state = _state;
                this.format = _format;
                this.reblogKey = _reblogKey;
                this.tags = _tags;
                this.shortUrl = _shortUrl;
                this.followed = _followed;
                this.highlighted = _highlighted;
                this.liked = _liked;
                this.noteCount = _noteCount;
                this.sourceUrl = _sourceUrl;
                this.sourceTitle = _sourceTitle;
                this.caption = StringEscapeUtils.escapeHtml4(_caption);
                this.linkUrl = _linkUrl;
                this.imagePermalink = _imagePermalink;
                this.photos = _photos;
                this.canReply = _canReply;
                this.postAuthor = _postAuthor;
            }

            @JsonProperty("blog_name")
            public String getBlogName() {
                return this.blogName;
            }

            @JsonProperty("id")
            public Long getId() {
                return this.id;
            }

            @JsonProperty("post_url")
            public String getPostUrl() {
                return this.postUrl;
            }

            @JsonProperty("slug")
            public String getSlug() {
                return this.slug;
            }

            @JsonProperty("type")
            public String getType() {
                return this.type;
            }

            @JsonProperty("date")
            public String getDate() {
                return this.date;
            }

            @JsonProperty("timestamp")
            public Long getTimestamp() {
                return this.timestamp;
            }

            @JsonProperty("state")
            public String getState() {
                return this.state;
            }

            @JsonProperty("format")
            public String getFormat() {
                return this.format;
            }

            @JsonProperty("reblog_key")
            public String getReblogKey() {
                return this.reblogKey;
            }

            @JsonProperty("tags")
            public List<Object> getTags() {
                return this.tags;
            }

            @JsonProperty("short_url")
            public String getShortUrl() {
                return this.shortUrl;
            }

            @JsonProperty("followed")
            public Boolean getFollowed() {
                return this.followed;
            }

            @JsonProperty("highlighted")
            public List<Object> getHighlighted() {
                return this.highlighted;
            }

            @JsonProperty("liked")
            public Boolean getLiked() {
                return this.liked;
            }

            @JsonProperty("note_count")
            public Long getNoteCount() {
                return this.noteCount;
            }

            @JsonProperty("source_url")
            public String getSourceUrl() {
                return this.sourceUrl;
            }

            @JsonProperty("source_title")
            public String getSourceTitle() {
                return this.sourceTitle;
            }

            @JsonProperty("caption")
            public String getCaption() {
                return this.caption;
            }

            @JsonProperty("link_url")
            public String getLinkUrl() {
                return this.linkUrl;
            }

            @JsonProperty("image_permalink")
            public String getImagePermalink() {
                return this.imagePermalink;
            }

            @JsonProperty("photos")
            public List<Photo> getPhotos() {
                return this.photos;
            }

            @JsonProperty("can_reply")
            public Boolean getCanReply() {
                return this.canReply;
            }

            @JsonProperty("post_author")
            public String getPostAuthor() {
                return this.postAuthor;
            }

            @JsonAnyGetter
            public Map<String, Object> getAdditionalProperties() {
                return this.additionalProperties;
            }

            @JsonAnySetter
            public void setAdditionalProperty(final String name,
                final Object value) {
                this.additionalProperties.put(name, value);
            }

            @Override
            public String toString() {
                return ToStringBuilder.reflectionToString(this);
            }

            @Override
            public int hashCode() {
                return HashCodeBuilder.reflectionHashCode(this);
            }

            @Override
            public boolean equals(final Object other) {
                return EqualsBuilder.reflectionEquals(this, other);
            }
        }
    }
}
